/**
 *******************************************************************************
 * \brief   CAS EBX Project Work "Kaffeemaschine"
 *
 * \file    pool.h
 * \version 1.0
 * \date    30.05.2010
 * \author  Baehler Thomas, Liechti Beat, Sauter Marc,
 * \author  Vuksic Valentina, Zbinden Rene
 *
 * \remark  Last Modifications:
 * \remark  V1.0, 30.06.2010   Initial release
 * \remark  V1.1, 04.07.2010   Valentina's implementation of the pool
 * \remark  V1.2  07.07.2010   Changed interface to use create/delete functions
 * \remark  V1.3  12.07.2010   Updating documentation for doxygen
 *******************************************************************************
 **/

#ifndef POOL_H_
#define POOL_H_

/*
 *******************************************************************************
 * Imports (required for ADT structure)
 *******************************************************************************
 */

#include <semaphore.h>

/*
 *******************************************************************************
 * Global Type Definition (ADT Structure)
 *******************************************************************************
 */
/** \brief ADT structure for pool */
typedef struct _tPool
{
	/** \brief name of the shared memory and the semaphore as well */
	char* name;
	/** \brief path of the shared memory and the semaphore as well */
	char *path;
	/** \brief data structure mapped into shared memory */
	void *data;
	/** \brief size of the data structure */
	int size;
	/** \brief shared memory descriptor */
	int shm;
	/** \brief semaphore descriptor */
	sem_t *sem;
} tPool;

/*
 *******************************************************************************
 * Global Function Declaration
 *******************************************************************************
 */
extern int createPool(char *name, void *data, int size);
extern void deletePool(char *name);
extern tPool * openPool(char *name, int size);
extern int writeToPool(tPool *pool, void *data);
extern int readFromPool(tPool *pool, void *data);
extern int closePool(tPool *pool);

#endif /* POOL_H_ */

